package com.oocl.servlet.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.pojo.Customer;
import com.oocl.service.CustomerManager;
import com.oocl.service.factory.CustomerManagerFactory;

@WebServlet("/register.action")
public class RegisterActionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private CustomerManager customerManager = CustomerManagerFactory.getInstance();

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String cname = request.getParameter("cname");
		String cpwd = request.getParameter("cpwd");
		
		customerManager.addCustomer(new Customer(null, cname, cpwd));
		request.getSession().setAttribute("loginCustomerName", cname);
		response.sendRedirect("sec/home");
	}

}
